//
//  QuestionTableViewCell.m
//  MingShi
//
//  Created by MJiao on 15/6/26.
//  Copyright (c) 2015年 MJiao. All rights reserved.
//

#import "QuestionTableViewCell.h"

#import "UIImageView+AFNetworking.h"
#import "Question.h"
#import "ImgeUtil.h"

@implementation QuestionTableViewCell

- (void)setAnswerImageWithURL:(NSString *)url
             placeholderImage:(NSString *)placeholderImage{
    
    [self.ivScreenshot setImageWithURL:[NSURL URLWithString:url]  placeholderImage:[UIImage imageNamed:placeholderImage]];
    
     
}

- (void)setAnswerImageWithURL: (NSString *)url
       placeholderImage:(NSString *)placeholderImage success:(void (^)(UIImage* image))success
                failure:(void (^)(NSError *error))failure{
       [self.ivScreenshot setImageWithURL:[NSURL URLWithString:url]  placeholderImage:[UIImage imageNamed:placeholderImage] success:success failure:failure];
}
- (IBAction)btnGoPostAnswerAction:(id)sender {
    NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
    [nc postNotificationName:@"postAnswerAction" object:self userInfo:[NSDictionary dictionaryWithObject:self.question forKey:@"question"]];
}

//
//- (void)layoutSubviews {
//    [super layoutSubviews];
//
//    UIImageView *ivScreenshot = self.ivScreenshot;
//    NSLog(@">>>>>%@",self.lbTitle);
//    if (ivScreenshot.image.size.width > 0) {
//        float frameWidt = ivScreenshot.frame.size.width;
//        CGSize newSize = CGSizeMake(frameWidt, ivScreenshot.image.size.height * frameWidt / ivScreenshot.image.size.width);
//
//
//        ivScreenshot.image = [ImgeUtil imageWithImage:ivScreenshot.image scaledToSize:newSize];
//
//        CGRect oldRect = ivScreenshot.frame;
//
//        NSLog(@"oldRect:(%f,%f)",oldRect.size.width,oldRect.size.height);
//
//        self.ivScreenshot.frame = CGRectMake(oldRect.origin.x, oldRect.origin.y, newSize.width, newSize.height);
//        oldRect = ivScreenshot.frame;
//         NSLog(@"NewRect:(%f,%f)",oldRect.size.width,oldRect.size.height);
//    }
//}
@end
